<!DOCTYPE html>
<html>
<head>
<title>git</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
/* GitHub stylesheet for MarkdownPad (http://markdownpad.com) */
/* Author: Nicolas Hery - http://nicolashery.com */
/* Version: b13fe65ca28d2e568c6ed5d7f06581183df8f2ff */
/* Source: https://github.com/nicolahery/markdownpad-github */

/* RESET
=============================================================================*/

html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
}

/* BODY
=============================================================================*/

body {
  font-family: Helvetica, arial, freesans, clean, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #333;
  background-color: #fff;
  padding: 20px;
  max-width: 960px;
  margin: 0 auto;
}

body>*:first-child {
  margin-top: 0 !important;
}

body>*:last-child {
  margin-bottom: 0 !important;
}

/* BLOCKS
=============================================================================*/

p, blockquote, ul, ol, dl, table, pre {
  margin: 15px 0;
}

/* HEADERS
=============================================================================*/

h1, h2, h3, h4, h5, h6 {
  margin: 20px 0 10px;
  padding: 0;
  font-weight: bold;
  -webkit-font-smoothing: antialiased;
}

h1 tt, h1 code, h2 tt, h2 code, h3 tt, h3 code, h4 tt, h4 code, h5 tt, h5 code, h6 tt, h6 code {
  font-size: inherit;
}

h1 {
  font-size: 28px;
  color: #000;
}

h2 {
  font-size: 24px;
  border-bottom: 1px solid #ccc;
  color: #000;
}

h3 {
  font-size: 18px;
}

h4 {
  font-size: 16px;
}

h5 {
  font-size: 14px;
}

h6 {
  color: #777;
  font-size: 14px;
}

body>h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h4:first-child, body>h5:first-child, body>h6:first-child {
  margin-top: 0;
  padding-top: 0;
}

a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
  margin-top: 0;
  padding-top: 0;
}

h1+p, h2+p, h3+p, h4+p, h5+p, h6+p {
  margin-top: 10px;
}

/* LINKS
=============================================================================*/

a {
  color: #4183C4;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* LISTS
=============================================================================*/

ul, ol {
  padding-left: 30px;
}

ul li > :first-child, 
ol li > :first-child, 
ul li ul:first-of-type, 
ol li ol:first-of-type, 
ul li ol:first-of-type, 
ol li ul:first-of-type {
  margin-top: 0px;
}

ul ul, ul ol, ol ol, ol ul {
  margin-bottom: 0;
}

dl {
  padding: 0;
}

dl dt {
  font-size: 14px;
  font-weight: bold;
  font-style: italic;
  padding: 0;
  margin: 15px 0 5px;
}

dl dt:first-child {
  padding: 0;
}

dl dt>:first-child {
  margin-top: 0px;
}

dl dt>:last-child {
  margin-bottom: 0px;
}

dl dd {
  margin: 0 0 15px;
  padding: 0 15px;
}

dl dd>:first-child {
  margin-top: 0px;
}

dl dd>:last-child {
  margin-bottom: 0px;
}

/* CODE
=============================================================================*/

pre, code, tt {
  font-size: 12px;
  font-family: Consolas, "Liberation Mono", Courier, monospace;
}

code, tt {
  margin: 0 0px;
  padding: 0px 0px;
  white-space: nowrap;
  border: 1px solid #eaeaea;
  background-color: #f8f8f8;
  border-radius: 3px;
}

pre>code {
  margin: 0;
  padding: 0;
  white-space: pre;
  border: none;
  background: transparent;
}

pre {
  background-color: #f8f8f8;
  border: 1px solid #ccc;
  font-size: 13px;
  line-height: 19px;
  overflow: auto;
  padding: 6px 10px;
  border-radius: 3px;
}

pre code, pre tt {
  background-color: transparent;
  border: none;
}

kbd {
    -moz-border-bottom-colors: none;
    -moz-border-left-colors: none;
    -moz-border-right-colors: none;
    -moz-border-top-colors: none;
    background-color: #DDDDDD;
    background-image: linear-gradient(#F1F1F1, #DDDDDD);
    background-repeat: repeat-x;
    border-color: #DDDDDD #CCCCCC #CCCCCC #DDDDDD;
    border-image: none;
    border-radius: 2px 2px 2px 2px;
    border-style: solid;
    border-width: 1px;
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
    line-height: 10px;
    padding: 1px 4px;
}

/* QUOTES
=============================================================================*/

blockquote {
  border-left: 4px solid #DDD;
  padding: 0 15px;
  color: #777;
}

blockquote>:first-child {
  margin-top: 0px;
}

blockquote>:last-child {
  margin-bottom: 0px;
}

/* HORIZONTAL RULES
=============================================================================*/

hr {
  clear: both;
  margin: 15px 0;
  height: 0px;
  overflow: hidden;
  border: none;
  background: transparent;
  border-bottom: 4px solid #ddd;
  padding: 0;
}

/* TABLES
=============================================================================*/

table th {
  font-weight: bold;
}

table th, table td {
  border: 1px solid #ccc;
  padding: 6px 13px;
}

table tr {
  border-top: 1px solid #ccc;
  background-color: #fff;
}

table tr:nth-child(2n) {
  background-color: #f8f8f8;
}

/* IMAGES
=============================================================================*/

img {
  max-width: 100%
}
</style>
</head>
<body>
<h1>git</h1>
<p>Git是一个开源的分布式版本控制系统，用于敏捷高效地处理任何或小或大的项目。</p>
<p>Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件。</p>
<p>软件在开发的过程，不停的有新功能和修复bug，这样软件的代码会不停的增加和变化，需要一个工具记录这个软件不同时期的任何一个版本。这个工具就是版本控制软件。</p>
<p>版本控制软件：里面保存的是软件的代码。</p>
<p>常见的版本控制软件:svn、git、CVS、Subversion </p>
<p>Git 与常用的版本控制工具 CVS, Subversion 等不同，它采用了分布式版本库的方式，不必服务器端软件支持。</p>
<h2>github</h2>
<p>gitHub是一个面向开源及私有软件项目的托管平台，因为只支持git 作为唯一的版本库格式进行托管，故名gitHub</p>
<p>github是一个基于git作为底层技术的网站平台。</p>
<p>Built for developers  专门为开发者而生</p>
<p>The world’s leading software development platform · GitHub</p>
<p>全世界领先的软件开发平台</p>
<p>GitHub is a development platform inspired by the way you work. From open source to business, you can host and review code, manage projects, and build software alongside millions of other developers.</p>
<p>目前github被微软收购了</p>
<p>官方网站：</p>
<pre><code>https://github.com/
</code></pre>

<h2>gitlab</h2>
<p>GitLab 是一个用于仓库管理系统的开源项目，使用Git作为代码管理工具，并在此基础上搭建起来的web服务。安装方法是参考GitLab在GitHub上的Wiki页面。</p>
<p>自己的在Linux系统里搭建的一个github。</p>
<h2>gitbook</h2>
<p>GitBook 是一个基于 Node.js 的命令行工具，可使用 Github/Git 和 Markdown 来制作精美的电子书。</p>
<h2>码云</h2>
<p>码云专为开发者提供稳定、高效、安全的云端软件开发协作平台
无论是个人、团队、或是企业，都能够用码云实现代码托管、项目管理、协作开发</p>
<p>码云：中国版的github</p>
<p>官方网站</p>
<pre><code>https://gitee.com/
</code></pre>

<p>去注册一个账号：可以是QQ账号</p>
<p>这个账号需要牢记用户名和密码，今后每天会使用</p>
<h2>安装windows版的git</h2>
<p>去官方网站下载，安装后右击，能看到下面效果，说明安装成功</p>
<p><img src="https://i.imgur.com/xWHmV81.png" /></p>
<h1>git和码云结合的使用案例操作</h1>
<p>1.打开pycharm，将里面的项目上传到码云
<img src="https://i.imgur.com/uyST0qz.jpg" /></p>
<p>2.进入d:\wangdalei文件夹，右击打开“git bash here”
<img src="https://i.imgur.com/nPv4XDF.jpg" /></p>
<p><img src="https://i.imgur.com/qOOOrg7.jpg" /></p>
<p>3.克隆码云里的项目到本地
<img src="https://i.imgur.com/yGt2qYF.jpg" /></p>
<pre><code>$ git clone https://gitee.com/cali/dengjianguo.git #克隆到本地电脑里
Cloning into 'dengjianguo'...
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 7 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (7/7), done.

cali@cali-PC MINGW64 /d/wangdalei
$
$ ls  #查看多了一个dengjianguo文件夹
__pycache__/           dengjianguo/  djg11.py  djg2.py  djg8.py
aa.txt                 dist/         djg12.py  djg3.py  djg9.py
backup/                dist-bak/     djg15.py  djg5.py  setup.py
caliosinfo5/           djg1.py       djg16.py  djg6.py  systemmonitor/
caliosinfo5.egg-info/  djg10.py      djg19.py  djg7.py  systemmonitor.egg-info/

cali@cali-PC MINGW64 /d/wangdalei  
$ cd dengjianguo/  #进入文件夹

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)
$ ls
LICENSE  README.md

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)
$
</code></pre>

<p>4.将需要上传的文件全部移动到dengjianguo文件夹下，自己在windows里操作完成</p>
<pre><code>cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)
$ ls -a
./          aa.txt     djg11.py  djg2.py  djg8.py    systemmonitor/
../         dist/      djg12.py  djg3.py  djg9.py    systemmonitor.egg-info/
.git/       dist-bak/  djg15.py  djg5.py  LICENSE
.gitee/     djg1.py    djg16.py  djg6.py  README.md
.gitignore  djg10.py   djg19.py  djg7.py  setup.py

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)
$
</code></pre>

<p>5.配置好用户名和邮箱地址，用户名不是中文，是英文的那个名字</p>
<pre><code>cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)
$ git config --global user.name &quot;cali&quot; #配置用户名

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)
$ git config --global user.email &quot;695811769@qq.com&quot; #配置邮箱

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)
$
</code></pre>

<p>6.将当前目录下所有的文件和文件夹，添加到本地的版本库里缓存里</p>
<p>$ git add .     #添加内容到缓存库里  .代表当前文件夹里的内容</p>
<p>cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)
$
7.提交内容到版本库里</p>
<pre><code>$ git commit -m  &quot;first&quot;  #提交到版本库
-m 是注释，这次提交的内容是什么
[master b0dc80a] first
 45 files changed, 708 insertions(+)
 create mode 100644 aa.txt
 create mode 100644 dist-bak/caliosinfo5-1.0.2.tar.gz
 create mode 100644 dist-bak/caliosinfo5-1.0.2/caliosinfo5-1.0.2/PKG-INFO
 create mode 100644 dist-bak/caliosinfo5-1.0.2/caliosinfo5-1.0.2/setup.py
 create mode 100644 dist-bak/djg13.py
 create mode 100644 dist-bak/djg17.py
 create mode 100644 dist-bak/djg18.py
 create mode 100644 dist-bak/djg19.py
 create mode 100644 dist-bak/djg4.py
 create mode 100644 djg1.py
 create mode 100644 djg10.py
 create mode 100644 djg11.py
 create
em/student.txt

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)
$
</code></pre>

<p>8.上传到码云</p>
<pre><code>cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)
$ git push  #上传到码云
Counting objects: 48, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (45/45), done.
Writing objects: 100% (48/48), 17.05 KiB | 256.00 KiB/s, done.
Total 48 (delta 2), reused 0 (delta 0)
remote: Powered by Gitee.com
To https://gitee.com/cali/dengjianguo.git
   173fcfd..b0dc80a  master -&gt; master

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)
$

提示：第一次上传会提醒你输入用户名和密码，用户名一定是英文的
</code></pre>

<p>9.到码云里查看是否有上传文件</p>
<p><img src="https://i.imgur.com/GwUOA7L.jpg" /></p>
<h3>总结过程：</h3>
<pre><code>1.码云gitee里新建一个项目
2.进入pycharm 里的一个项目的文件夹目录位置
3.使用git clone 下载项目到pychar项目的文件夹目录下
4.配置gitee里的用户名和邮箱

    git config  --global user.name  &quot;cali&quot;
    git config  --global user.email &quot;695811769@qq.com&quot;
5.添加内容到缓存库
    git add .  添加我们新建的文件到git里
6.提交内容到版本库
    git commit -m &quot;frist commit&quot;  #提交添加进来的文件到git
7.推送内容到码云gitee里
    git push #将本地的添加进来的文件上传到码云里
8.到码云里查看是否上传成功
</code></pre>

<h2>git的原理</h2>
<ul>
<li>branch  分支</li>
<li>
<p>master  主版本</p>
</li>
<li>
<p>稳定版本：一般是修复bug</p>
</li>
<li>开发版本：一般都是加新功能</li>
</ul>
<p>release:发布</p>
<p>fix：修复</p>
<p>hotfixs:热修复bug</p>
<p>feature：特色</p>
<p><img src="https://i.imgur.com/ZodZDBi.png" /></p>
<p><img src="https://i.imgur.com/qQad3KO.png" /></p>
<p><strong>基本概念</strong></p>
<p>我们先来理解下Git 工作区、暂存区和版本库概念</p>
<p>工作区：就是你在电脑里能看到的目录。</p>
<p>暂存区：英文叫stage, 或index。一般存放在 &quot;.git目录下&quot; 下的index文件（.git/index）中，所以我们把暂存区有时也叫作索引（index）。</p>
<p>版本库：工作区有一个隐藏目录.git,是Git的版本库。</p>
<p><img src="https://i.imgur.com/HV6PnyB.jpg" /></p>
<h3>分支的操作</h3>
<p>先在码云上创建分支wulongshan，然后到本地电脑里创建分支wulongshan，名字一样就可以</p>
<p><img src="https://i.imgur.com/LNrCGW0.jpg" /></p>
<p><img src="https://i.imgur.com/QmEbIVA.jpg" /></p>
<pre><code>cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)
$ git branch wulongshan #新建分支wulongshan

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)
$ git checkout wulongshan #切换分支到wulongshan，原来在master上
Switched to branch 'wulongshan'

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (wulongshan)
$ git status #查看当前的状态
On branch wulongshan
nothing to commit, working tree clean

cali@cali-PC MINGW64
</code></pre>

<p>自己在wangdalei文件夹下，新建一个yinxiang.py文件，写入一些代码</p>
<pre><code>$ git add .

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (wulongshan)
$ git commit -m &quot;add yinxiang.py&quot;
[wulongshan 85df16a] add yinxiang.py
 1 file changed, 23 insertions(+)
 create mode 100644 yinxiang.py

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (wulongshan)
$
</code></pre>

<p>--set-upstream origin  上游的源（码云上的分支源头）</p>
<p>upstream 上游  origin  源</p>
<blockquote>
<p>默认情况下git push会上传到master分支上，上传到其他分支需要指定下分支的名字</p>
</blockquote>
<p>将添加进来的文件上传到wulongshan源里</p>
<pre><code>$  git push --set-upstream origin wulongshan
Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 259 bytes | 64.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Powered by Gitee.com
To https://gitee.com/cali/dengjianguo.git
   b0dc80a..85df16a  wulongshan -&gt; wulongshan
Branch 'wulongshan' set up to track remote branch 'wulongshan' from 'origin'.

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (wulongshan)
$
</code></pre>

<p>切换到master分支上</p>
<pre><code>$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)
$
</code></pre>

<h2>merge 合并分支</h2>
<p>merge：合并</p>
<pre><code>$ git checkout master #首选切换到master分支上
Switched to branch 'master'
Your branch is up to date with 'origin/master'.

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)
$ ls
aa.txt     djg10.py  djg16.py  djg5.py  djg9.py    systemmonitor/
dist/      djg11.py  djg19.py  djg6.py  LICENSE    systemmonitor.egg-info/
dist-bak/  djg12.py  djg2.py   djg7.py  README.md
djg1.py    djg15.py  djg3.py   djg8.py  setup.py

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)
$ git status #查看当前的状态
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)

$ git merge wulongshan  #合并分支wulongshan
Updating b0dc80a..85df16a
Fast-forward
 yinxiang.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 yinxiang.py

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)

$ git push #上传到码云
Total 0 (delta 0), reused 0 (delta 0)
remote: Powered by Gitee.com
To https://gitee.com/cali/dengjianguo.git
   b0dc80a..85df16a  master -&gt; master

cali@cali-PC MINGW64 /d/wangdalei/dengjianguo (master)
$
</code></pre>

<p>最后到码云上查看master分支里的内容，是否已经包含wulongshan分支里的内容。</p>
<h2>项目合作</h2>
<h2>pull requests</h2>

</body>
</html>
<!-- This document was created with MarkdownPad, the Markdown editor for Windows (http://markdownpad.com) -->
